package com.nanjing.east.cloud;

import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;

import javax.sql.DataSource;
import java.sql.SQLException;

/**
 * 数据源配置
 *
 * @author xiechao260
 * @date 2018年8月11日
 * @since 1.0.0
 */
@Configuration
@EnableJpaAuditing
public class DataSourceConfiguration {

    @Bean(name = "payGatewayDataSource", destroyMethod = "close", initMethod = "init")
    @ConfigurationProperties(prefix = "spring.datasource.pay.gateway")
    public DataSource payGatewayDataSource() throws SQLException {
        return DataSourceBuilder.create().type(DruidDataSource.class).build();
    }

}
